package com.bolt.admin.web.controller;

import com.bolt.admin.common.base.BaseController;
import com.bolt.admin.module.log.dto.LogDTO;
import com.bolt.admin.module.log.entity.LogEntity;
import com.bolt.admin.module.log.service.LogService;
import com.bolt.convention.data.PageInfo;
import com.bolt.convention.data.ResultMessage;
import com.bolt.convention.data.Returns;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * Auto Generate Javadoc
 *
 * @author 日期:2020-10-16 10:59:58
 *         系统日志
 **/
@Controller
@RequestMapping("/admin/sys/log")
public class LogController extends BaseController<LogEntity, Long> {

    @Autowired
    private LogService logService;


    /**
     * 模块首页
     */
    @RequestMapping(value = "", method = RequestMethod.GET)
    public ModelAndView index(Model model, HttpServletRequest request) {
        return super.index("/admin/sys/log/index", request, model.asMap());
    }

    /**
     * 系统日志列表分页
     *
     * @return
     */
    @RequestMapping(value = "page", method = RequestMethod.POST)
    @ResponseBody
    public ResultMessage list(Pageable pageable, LogDTO dto) {
        PageInfo<LogDTO> data = logService.findPage(pageable, dto);
        return Returns.success(data);

    }


}